package com.guigu.service.impl;


import com.github.pagehelper.PageInfo;
import com.guigu.dto.MemberDTO;
import com.guigu.dto.UpdateMemberRequest;
import com.guigu.entity.*;
import com.guigu.mapper.MemberMapper;
import com.guigu.service.MemberService;
import com.guigu.vo.InformationVo;
import com.guigu.vo.MemberVo1;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
@Transactional
public class MemberServiceImpl implements MemberService {
    @Autowired
    private MemberMapper memberMapper;

    @Override
    public List<MemberVo1> findAllUserList() {
        return this.memberMapper.findAllUserList();
    }

    @Override
    public void add(MemberDTO dto) {
        dto.setRegTime(new Date());
         this.memberMapper.add(dto);
        System.out.println("id"+dto.getId());
        this.memberMapper.addinfo(dto.getId());
        this.memberMapper.addhistory(dto.getId());
    }

    @Override
    public void Del(int id) {
        this.memberMapper.Del(id);
    }

    @Override
    public MemberVo1 findOne(int id) {
        return this.memberMapper.findOne(id);
    }

    @Override
    public InformationVo findOne1(int id) {
        return this.memberMapper.findOne1(id);
    }

    @Override
    public t_History findOne2(int id) {
        return this.memberMapper.findOne2(id);
    }

    @Override
    public void updatemember(UpdateMemberRequest request) {
        this.memberMapper.updatemember(request.getDto());
        this.memberMapper.updateinfo(request.getInfo());
        this.memberMapper.updatehistory(request.getHistory());
    }

    @Override
    public List<t_account> user() {
        return this.memberMapper.user();
    }

    @Override
    public List<MemberVo1> statistics(t_statistics dto) {
        return this.memberMapper.statistics(dto);
    }
}
